package cn.max.services;

import cn.incontent.cda.client.common.ArgumentList;
import cn.incontent.fastjson.JSONArray;
import cn.incontent.fastjson.JSONObject;
import cn.max.controllers.ADService;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 *@author Val.(Valentine Vincent) E-mail:valer@126.com
 *@version 1.0
 *@date 2014-7-23
 *Instruction : 
 **/
public class TestService extends ADService {

	public static SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

	public void test() throws  Exception {

		ArgumentList args = getArgs();
		JSONObject result = new JSONObject();
		result.put("total", 500);
		result.put("current", Integer.parseInt(args.get("current")));
		result.put("rowCount", Integer.parseInt(args.get("rowCount")));

		JSONArray arr = new JSONArray();


		for (int i = 0; i < Integer.parseInt(args.get("rowCount")); i ++) {
			JSONObject item = new JSONObject();
			item.put("id", i);
			item.put("sender", "max" + i + "@gmail.com");
			item.put("received", SDF.format(new Date()));
			arr.add(item);
		}

		result.put("rows", arr);
		out(result);

	}

	
}
